<?
define("KEY", "ABQIAAAAiO3_gTVoVOf54azjqgeqwxS5ypMzmKSbJW4pMQDx-R0VujuVqhTX_zF0keI0ak2VO_S3NP4c14rJnw");
require_once('lib/db/db.php');
$db = new DBConnection('dbname=assclap_realty port=5432 user=assclap_assclap password=fibo1235');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<LINK REL="SHORTCUT ICON" HREF="favicon.ico">
<!-- CSS -->
<link type="text/css" href="lib/jqPlugins/jQueryUI/css/hot-sneaks/jquery-ui-1.8.7.custom.css" rel="stylesheet" />
<link type="text/css" rel="stylesheet" href="lib/jqPlugins/jquery.layout.all-1.2.0/layout-default-latest.css" />
<link type="text/css" href="css/index.css" media="all" rel="stylesheet" />
<!-- End CSS -->
<!-- Javascript -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js"></script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
<!--script type="text/javascript" src="http://www.google.com/jsapi?key=<? //echo KEY; ?>"></script-->
<script type="text/javascript" src="js/map-datatable.js"></script>
<script type="text/javascript" src="lib/jqPlugins/markerclusterer/src/markerclusterer.js"></script>
<script type="text/javascript" src="lib/jqPlugins/jquery.cookie.js"></script>
<script type="text/javascript" src="lib/jqPlugins/jqGmapsPolygon/polygon(1.0).js"></script>
<script type="text/javascript" src="lib/jqPlugins/jquery.layout.all-1.2.0/jquery.layout.min.js"></script>
<script type="text/javascript" src="lib/jqPlugins/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<!-- End Javascript -->
<title>House Hunter Prototype</title>
</head>
<body>
<div id="container">
  <div class="pane ui-layout-center">
    <div id="inner-container">
      <div class="pane ui-layout-center">
        <div id="properties">
          <div class="ui-widget-header"><em>Search: </em>
            <input id="search" name="search" type="text" width="400px" />
            <em>Rating: </em>
            <select id="rating">
              <option value="">All</option>
              <option value="-2">Shithole: visited</option>
              <option value="-1">Not interested</option>
              <option value="0">Unrated</option>
              <option value="1">Flagged for visit</option>
              <option value="2">Visted and it's awesome</option>
            </select>
            <span id="filter_info"></span> </div>
        </div>
      </div>
      <div class="pane ui-layout-north">
        <div id="map_canvas"></div>
      </div>
    </div>
  </div>
  <div class="pane ui-layout-west">
    <div id="accordion">
      <h3><a href="#">Tools</a></h3>
      <div>
        <input type="checkbox" class="toggle-button" id="polygon-mode" />
        <label for="polygon-mode">Polygon Toggle <span class="ui-icon ui-icon-comment"></span></label>
        <a class="button" href="javascript:return false;" id="exportKMLForOV2">Export KML for TomTom</a> <a class="button" href="javascript:return false;" id="exportKMLForEarth">Export KML for Earth</a> 
        <!-- Google Public Location Badge -->
<iframe src="http://www.google.com/latitude/apps/badge/api?user=6272458244145390506&type=iframe&maptype=roadmap" width="180" height="300" frameborder="0"></iframe>
<!-- To disable location sharing, you *must* visit https://www.google.com/latitude/apps/badge and disable the Google Public Location badge. Removing this code snippet is not enough! --></div>
      <h3><a href="#">Layers</a></h3>
      <div>
        <?
$sql = "select distinct * from overlay";
$Query = $db->CreateQuery($sql);
while($row = $Query->FetchObject())
{
?>
        <div class="checkdiv">
          <input type="checkbox" class="layerCheck" name="<? echo urlencode($row->name); ?>" id="<? echo urlencode($row->name); ?>" value="<? echo urlencode($row->url); ?>" <? if(isset($_COOKIE['Layer' .  urlencode($row->name)])) echo "checked"; ?> />
          <label for="<? echo urlencode($row->name); ?>"><? echo "$row->name"; ?></label>
        </div>
        <?
}
?>
      </div>
      <h3><a href="#">Filter by Zip</a></h3>
      <div>
        <?
$sql = "select distinct zip, city, count(*) as cunt from property where zip is not null and zip <> '' group by zip, city order by cunt desc";
$Query = $db->CreateQuery($sql);
while($row = $Query->FetchObject())
{
?>
        <div class="divCheck">
          <input type="checkbox" class="zipCheck" name="check<? echo urlencode($row->zip); ?>" id="check<? echo urlencode($row->zip); ?>" value="<? echo $row->zip; ?>" <? if(isset($_COOKIE['check' . urlencode($row->zip)])) echo "checked"; ?> />
          <label for="check<? echo urlencode($row->zip); ?>"><? echo "$row->zip ($row->city) ($row->cunt)"; ?></label>
        </div>
        <?
}
?>
      </div>
      <h3><a href="#">Filter by City</a></h3>
      <div>
        <?
$sql = "select distinct city, count(*) as cunt from property where city is not null and city <> '' group by city order by cunt desc";
$Query = $db->CreateQuery($sql);
while($row = $Query->FetchObject())
{
?>
        <div class="checkdiv">
          <input type="checkbox" class="cityCheck" name="check<? echo urlencode($row->city); ?>" id="check<? echo urlencode($row->city); ?>" value="<? echo $row->city; ?>" <? if(isset($_COOKIE['check' .  urlencode($row->city)])) echo "checked"; ?> />
          <label for="check<? echo urlencode($row->zip); ?>"><? echo "$row->city, ($row->cunt)"; ?></label>
        </div>
        <?
}
?>
      </div>
    </div>
  </div>
</div>
<div id="logo" class="ui-widget-header">House Hunter Prototype<br />
<span id="sql"></span></div>
<? include('lib/propertywindow.php'); ?>
<div id="polygonCreationDialog" style="" title="Save your polygon">
  <form>
    <fieldset>
      <label for="name">Name</label>
      <input type="text" name="name" id="name" class="text ui-widget-content ui-corner-all" />
      <label for="color">Color</label>
      <div id="red"></div>
      <div id="green"></div>
      <div id="blue"></div>
      <div id="swatch" class="ui-widget-content ui-corner-all"></div>
      <input type="text" name="color" id="color" value="" class="text ui-widget-content ui-corner-all" />
      <label for="description">Description</label>
      <textarea name="description" cols="60" rows="4" class="text ui-widget-content ui-corner-all" id="description" value="" ></textarea>
    </fieldset>
  </form>
</div>
</body>
</html>